home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!genesis.demon.co.uk
- From: Lawrence Kirby <fred@genesis.demon.co.uk>
- Newsgroups: comp.lang.c
- Subject: Re: simple code, argc, argv, strcmp()
- Date: Tue, 06 Feb 96 14:04:25 GMT
- Organization: none
- Message-ID: <823615465snz@genesis.demon.co.uk>
- References: <11f7cc$17261a.3b3@daprez> <4etj7c$bma@news.iag.net> <fcusack-0202961621470001@mudskipper.cac.psu.edu> <4f0rjn$sfh@news.iag.net>
- Reply-To: fred@genesis.demon.co.uk
- X-NNTP-Posting-Host: genesis.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.27
- X-Mail2News-Path: genesis.demon.co.uk
-
- In article <4f0rjn$sfh@news.iag.net> jatmon@iag.net "John R Buchan" writes:
-
- >You are correct, of course. Stupidity on my part. I tend to get careless
- >about strcmp's reverse logic (ie returns False, when the strings match), when
- >I am not paying attention (not an excuse, just an explanation). I normally
- >compare the return value to 0, just to keep myself straight.
-
-
- That's the point though - strcmp() simply doesn't return a boolean value so
- saying 'ie returns False' is just plain wrong and is what gets you into
- trouble. strcmp() is in some sense more like a difference operation. e.g.
- (ignoring overflow) if you take 2 integers a and b and calculate a-b the
- result is >0 if a is larger, ==0 if they are equal and <0 if a is smaller,
- just as strcmp(sa,sb) is defined. IMHO the definition of strcmp is quite
- natural (but maybe the name doesn't quite reflect that definition).
-
- --
- -----------------------------------------
- Lawrence Kirby | fred@genesis.demon.co.uk
- Wilts, England | 70734.126@compuserve.com
- -----------------------------------------
-